#include <cstring>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>

using namespace std;
#define MAXN 1005

int tcase,n;
vector < pair<int,int> > V;
bool T[MAXN];

int main(){
  cin>>tcase;
  for(int tc=1; tc<=tcase; ++tc){
     cin>>n; V = vector< pair<int,int> > (n);
     for(int i=0; i<n; ++i){
        cin>> V[i].second >> V[i].first; V[i].second *= -1;  
     }
     sort(V.begin(),V.end());
     int count = 0; bool ispossible = true; 
     memset(T,false,sizeof(T));     
     for(int i=0; i<n; ++i){
       while(count<V[i].first){
          bool changed = false;
          for(int j=n-1; j>=i; --j) if(-V[j].second <= count && T[j]==false ) {
              T[j] = true; count += 1;  changed = true; break; 
          }  
          if(changed==false) break;
       }
       if(V[i].first <= count ) {
         if(T[i]==true) count += 1; else count += 2; 
       }
       else {
         ispossible = false;  break; 
       }
     }
     int ct = 0; for(int i=0; i<n; ++i) if(T[i]) ++ct;
     cout << "Case #"<<tc<<": ";
     if(ispossible) cout<<ct+n; else cout<<"Too Bad"; 
     cout<<endl;
  } 
  return 0;
}
